package controller

import (
	"gin-shop-admin/repository"
	"github.com/gin-gonic/gin"
	"net/http"
)

func GetOrders(c *gin.Context)  {
	query := c.Query("query")
	pageNum := c.Query("pagenum")
	pageSize := c.Query("pagesize")
	orders, total, err := repository.GetOrderList(query, pageNum, pageSize)
	if err != nil {
		c.JSON(201, gin.H{"msg": err, "data": nil})
	}else{
		c.JSON(http.StatusOK, gin.H{"msg": "success", "data": map[string]interface{}{"orders": orders,"total": total}})
	}
	return
}
